package br.com.statizo.financeiro.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

import br.com.statizo.financeiro.service.CalendarService;

public class AbasComposite extends Composite {

	public AbasComposite(Composite parent, int style) {
		super(parent, style);
		// TODO Auto-generated constructor stub
	}

//	
//	//@Autowired
//	private CalendarService calendarService;
//	
//	//@Autowired
//	private TabFolder tabFolder; 
//	
//	//@Autowired
//	private Group calendarGroup;
//	
//	//@Autowired
//	//private LancamentoTable lancamentoTable;
//	
//	
//	
//	public AbasComposite(Composite parent, int style) {
//		super(parent, style);
//	}
//
//	
//	protected void setUpFolder(){
//
//		this.setLayout(new FormLayout());
//
//		FormData formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(100,0);		
//		formData.left = new FormAttachment(0,0);		
//		formData.right = new FormAttachment(100,0);
//		tabFolder.setLayoutData(formData);
//		tabFolder.setLayout(new FormLayout());
//		
//	}
//	
//	protected void setUpCalendarList(){
//		
//		FormData formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(100,0);		
//		formData.left = new FormAttachment(2,0);		
//		formData.right = new FormAttachment(30,0);
//
//		calendarGroup.setText("Selecione um mês");
//		calendarGroup.setLayoutData(formData);
//		//calendarGroup.setLayout(new FormLayout());
//		
//		
//		final List calendarList = new List(calendarGroup,SWT.BORDER);
//		calendarList.setItems(calendarService.getMonthNames());
//		calendarList.setSelection( calendarService.getSelectedMonth() + 1);
//	
//		calendarList.addSelectionListener(new SelectionAdapter() {
//		
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//
//				int selected = calendarList.getSelectionIndex();
//				int last = calendarList.getItemCount() - 1;
//				int prevLast =  calendarList.getItemCount() - 2;
//				
//				if(selected == 0)
//					calendarService.setPreviousYear();
//				else if(selected == prevLast)
//					calendarService.setNextYear();
//				else if(selected == last)
//					calendarService.setCurrentYear();
//				else 
//					calendarService.setSelectedMonth(selected);
//
//				
//				if(selected == 0 || selected == last || selected == prevLast){
//					
//					calendarList.removeAll();
//					calendarList.setItems(calendarService.getMonthNames());
//				
//					if(selected == last){
//						calendarService.setCurrentMonth();
//					}else{
//						calendarService.setSelectedMonth(1);
//					}
//					
//					calendarList.setSelection(calendarService.getSelectedMonth() + 1);
//
//				}
//
//				
//			}
//		
//		
//		});
//		
//		
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(2,0);
//		formData.bottom = new FormAttachment(98,0);		
//		formData.left = new FormAttachment(3,0);		
//		formData.right = new FormAttachment(97,0);
//		
//		calendarList.setLayoutData(formData);
//		
//		/*
//		Image image = new Image(Display.getDefault(), "images/calendar.jpg");
//		Label label = new Label(calendarGroup, SWT.NONE);
//		label.setImage(image);
//		label.setLayoutData(formData);
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(15,0);		
//		formData.left = new FormAttachment(62,0);		
//		formData.right = new FormAttachment(100,0);
//		
//		label.setLayoutData(formData);
//		*/
//
//	}
//	
//	protected void setUpResumoPanel(){
//		
//		
//		TabItem tabItem = new TabItem(tabFolder, SWT.BORDER);
//		tabItem.setText("Resumo");
//		
//		Composite composite = new Composite(tabFolder, SWT.BORDER);
//		tabItem.setControl(composite);
//		
//		FormData formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(100,0);		
//		formData.left = new FormAttachment(32,0);		
//		formData.right = new FormAttachment(100,0);
//
//		composite.setLayoutData(formData);
//		composite.setLayout(new FormLayout());
//		//composite.setBackground(new Color(Display.getDefault(),0,0,0));
//		
//		Label label = new Label(composite, SWT.NONE);
//		label.setText("teste");
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(10,0);
//		formData.bottom = new FormAttachment(50,0);		
//		formData.left = new FormAttachment(0,0);		
//		formData.right = new FormAttachment(80,0);
//		
//		label.setLayoutData(formData);
//		
//		
//	}
//	
//	
//
//	public void createContents() {
//
//		//setUpFolder();
//		//setUpCalendarList();
//		//setUpResumoPanel();
//		
//		/*
//		this.setLayout(new FormLayout());
//
//		FormData formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(100,0);		
//		formData.left = new FormAttachment(0,0);		
//		formData.right = new FormAttachment(100,0);
//
//		tabFolder.setLayout(new FormLayout());
//		tabFolder.setLayoutData(formData);
//
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(3,0);
//		formData.bottom = new FormAttachment(90,0);		
//		formData.left = new FormAttachment(0,0);		
//		formData.right = new FormAttachment(20,0);
//		
//		calendarGroup.setText("Selecione o Mês");
//		calendarGroup.setLayoutData(formData);
//		calendarGroup.setLayout(new FormLayout());
//		
//
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(2,0);
//		formData.bottom = new FormAttachment(60,0);		
//		formData.left = new FormAttachment(3,0);		
//		formData.right = new FormAttachment(68,0);
//
//		final List calendarList = new List(calendarGroup,SWT.NONE);
//		calendarList.setItems(calendarService.getMonthNames());
//		calendarList.setLayoutData(formData);
//		calendarList.setSelection( calendarService.getSelectedMonth() + 1);
//	
//		calendarList.addSelectionListener(new SelectionAdapter() {
//		
//			@Override
//			public void widgetSelected(SelectionEvent e) {
//
//				int selected = calendarList.getSelectionIndex();
//				int last = calendarList.getItemCount() - 1;
//				int prevLast =  calendarList.getItemCount() - 2;
//				
//				if(selected == 0)
//					calendarService.setPreviousYear();
//				else if(selected == prevLast)
//					calendarService.setNextYear();
//				else if(selected == last)
//					calendarService.setCurrentYear();
//				else 
//					calendarService.setSelectedMonth(selected);
//
//				
//				if(selected == 0 || selected == last || selected == prevLast){
//					
//					calendarList.removeAll();
//					calendarList.setItems(calendarService.getMonthNames());
//				
//					if(selected == last){
//						calendarService.setCurrentMonth();
//					}else{
//						calendarService.setSelectedMonth(1);
//					}
//					
//					calendarList.setSelection(calendarService.getSelectedMonth() + 1);
//
//				}
//
//				
//			}
//		
//		
//		});
//		
//		
//		formData = new FormData();
//		formData.top = new FormAttachment(0,0);
//		formData.bottom = new FormAttachment(15,0);		
//		formData.left = new FormAttachment(72,0);		
//		formData.right = new FormAttachment(100,0);
//		
//		Image image = new Image(Display.getDefault(), "images/calendar.jpg");
//		Label label = new Label(calendarGroup, SWT.NONE);
//		label.setImage(image);
//		label.setLayoutData(formData);
//
//		formData = new FormData();
//		formData.top = new FormAttachment(0);
//		formData.bottom = new FormAttachment(100);		
//		formData.left = new FormAttachment(50);		
//		formData.right = new FormAttachment(100);
//
//		Composite composite = new Composite(tabFolder,SWT.BORDER);
//		composite.setLayout(new FormLayout());
//		composite.setLayoutData(formData);
//		
//		TabItem tabResumo = new TabItem(tabFolder, SWT.NONE);
//		tabResumo.setText("Resumo");
//		tabResumo.setControl(composite);
//		
//
//		
//		
////
////		TabItem tabControle = new TabItem(tabFolder, SWT.NONE);
////		tabControle.setText("Controle de Recursos Alocados");
//
//		
////		TabItem tabLancamentos = new TabItem(tabFolder, SWT.NONE);
////		tabLancamentos.setText("Lançamentos");
////		tabLancamentos.setControl(lancamentoTable);
////		
////		formData = new FormData();
////		formData.top = new FormAttachment(3,0);
////		formData.bottom = new FormAttachment(90,0);		
////		formData.left = new FormAttachment(30,0);		
////		formData.right = new FormAttachment(95,0);
////		lancamentoTable.setVisible(true);
////		lancamentoTable.configure();
////		lancamentoTable.setLayoutData(formData);
//		
//		
//		*/
//
//		
//	}
	
}